// 导入定义验证规则的包
const joi = require('@hapi/joi')
//  定义   nickname  email  验证规则
const nickname = joi.string().required()
const email = joi.string().email().required()
// 定义用户名和密码的验证规则
const username = joi.string().alphanum().min(1).max(10).required()
const password = joi
  .string()
  .pattern(/^[\S]{6,12}$/)
  .required()

const avatar = joi.string().dataUri().required()
exports.reg_login_schema = {
  body: { username, password }
}
//  更新用户信息的规则
exports.update_userinfo_schema = {
  body: { nickname, email }
}
//  更新密码的规则
exports.update_password_schme = {
  body: {
    oldPwd: password,
    newPwd: joi.not(joi.ref('oldPwd')).concat(password)
  }
}
// 验证规则对象 - 更新头像
exports.update_avatar_schema = {
  body: {
    avatar
  }
}
